







$(function(){


	//$(".f-pic>ul>img").lazyload({
	//	effect:"fadeIn",
	//	threshold:100,
	//	placeholder:"img/grey.gif"
	//});



	$(".p2").mouseover(function(){
		$(".shopping-bottom").show();
	});
		$(".landing_r>.p2").mouseleave(function(){
		$(".shopping-bottom").hide();
	});


	$(".landing_r>.p3").mouseenter(function(){
		$(".nav-bottom").show();
	});
		$("#navBottom").mouseenter(function(){
		$("#navBottom").show();
	});
		$("#navBottom").mouseleave(function(){
		$("#navBottom").hide();
	});

	$(".inpt").focus(function(){
		$(".laber").hide();
	});

	/***********轮播图*****************/

	var $cout;
	$.get("json/json1.json",function(data) {
		//console.log(data[0].lunbo);
		var  $cout = data[0].lunbo.length;
		var html = "";
		for(var i = 0;i<  $cout ;i++){
				html+=	"<li class=\"b"+ (i+1) +"\">"
					+"</li>";

		}
		$("#lbt").html(html);
		var html = "";
		for(var i = 0;i<  $cout ;i++){
			html+="<span>" +
				"</span>"
		}
		$(".dot").html(html);
		var setDot = function(countIndex){
			$(".dot>span").removeClass("on").eq(countIndex).addClass("on");
		};



		$("#lbt>li").eq(0).show();
		var countIndex = 0;
		setDot(countIndex);
		$(".prev").click(function(){
			countIndex--;
			$("#lbt>li").eq(countIndex + 1).hide();
			if(countIndex == -1){
				countIndex = $cout-1;
			}
			$("#lbt>li").eq(countIndex).fadeIn(400);
			setDot(countIndex);
		});

		var next = function(countIndex){
			$("#lbt>li").eq(countIndex - 1).hide();
			if(countIndex == $cout){
				countIndex = 0;
			}
			$("#lbt>li").eq(countIndex).fadeIn(400);
			setDot(countIndex);
		};

		$(".next").click(function(){
			countIndex++;
			next(countIndex);
		});

		$(".dot>span").click(function(){
			var $index = $(this).index();

			$( "#lbt>li").hide().eq($index).fadeIn(400);
			setDot($index);
		});

	var stop;
    var set = function(){
		clearInterval(stop);
		stop = setInterval(function(){
			countIndex++;
			next(countIndex);
		},3000)

	};
	set();
		$("#lbt").mouseenter(function(){
			clearInterval(stop);
		});
		$("#lbt").mouseleave(function(){
			set();
		})



	});


	/************轮播图下的板块**************/
	$.get("json/json1.json",function(data){
		var $arr = data[1].fenlei;
		var html = "";
		for(var i = 0;i<$arr.length;i++){
			html+=	"<li>" +
				"<a href = \"##\">" +
				"<img src = \""+$arr[i].pic+"\"/>" +
				"</a>" +
				"</li>";

		}
		$(".three>ul").html(html);


	});




	/***************f1-lb****************/



	$.get("json/json1.json",function(data){
		var $arr = data[2].f1lb;
		var html = "";

		for(var i = 0;i<$arr.length;i++){
			html+="<div class = \"lb-x\">"
				+"<img src = \""+$arr[i].pic+"\"/>"
				+"</div>";
		}
		html+="<div class = \"lb-x\">"
			+"<img src = \""+$arr[0].pic+"\"/>"
			+"</div>";
		$("#f1Lb>.lbt").html(html);

		var $texes = data[3].f1Txt;
		var html = "";
		for(var j = 0;j<$texes.length;j++){
			html+="<li>" +
				"<a href=\"##\">"+$texes[j].f1+"</a>" +
				"</li>";
		}
		$("#f1Lb>.lb-btn").html(html);

		var currindex = 0;
		var steCli = function(currindex){
			$("#f1Lb>.lb-btn>li").removeClass("color").eq(currindex).addClass("color");
		};

		$("#f1Lb>.lb-btn>li").click(function(){
			var currindex = $(this).index();
			$("#f1Lb>.lbt").animate({left:-952*currindex},300);

			steCli(currindex);
		});
		setInterval(function(){
			currindex++;
			if(currindex === 6){
				$("#f1Lb>.lbt").css({"left":"0"});
				currindex = 0;
			}else{
				$("#f1Lb>.lbt").animate({left:-952*currindex},300);
			}

			steCli(currindex);
		},4000);

	});


	/*****************f1-pic*******************/
	$.get("json/json1.json",function(data) {
		var $arr = data[4].f1Pic;
		var html = "";
		for (var i = 0; i < $arr.length; i++) {
			html += "<li id = \""+i+"\">" +
				"<a href=\"##\">" +
				"<dl>" +
				"<dt>" +
				"<img  src= \"" + $arr[i].pic + "\"/>" +
				"</dt>" +
				"<dd>" + $arr[i].nume + "</dd>" +
				"<p>" +
				"<i>" + $arr[i].price + "</i>" +
				"<del>" + $arr[i].onprice + "</del>" +
				"</p>" +
				"</dl>" +
				"</a>" +
				"</li>";
		}

		$(".f-pic>ul").html(html);



		/***将信息添加到cookie***/
		$(".f-pic>ul>li").click(function(){
			var $index = $(this).index();
			var id = $(".f-pic>ul>li").eq($index).attr("id");
			var pic = $(".f-pic>ul>li>a>dl>dt>img").eq($index).attr("src");
			var pnume = $(".f-pic>ul>li>a>dl>dd").eq($index).html();
			var price = $(".f-pic>ul>li>a>dl>p>i").eq($index).html();
			var str = id+"#"+pic+"#"+pnume+"#"+price+"#"+"1";
			var $shopcart = $.cookie("shopcart");
			if(!$shopcart){
				$.cookie("shopcart",str,{
					expires:7
				});
			}else{
				var result = strOper.add($shopcart,str);
				$.cookie("shopcart",result);
			}

		})


	});





	/*****************f2-轮播图************************/
	$.get("json/json1.json",function(data){
		var $arr = data[5].f2lb;
		var html = "";

		for(var i = 0; i < $arr.length;i++){
			html+="<div class = \"lb-x\">"
				+"<img src = \""+$arr[i].pic+"\"/>"
				+"</div>";
		}
		html+="<div class = \"lb-x\">"
			+"<img src = \""+$arr[0].pic+"\"/>"
			+"</div>";
		$("#f2Lb>.lbt").html(html);

		var $texes = data[6].f2Txt;
		var html = "";
		for(var j = 0;j<$texes.length;j++){
			html+="<li>" +
				"<a href=\"##\">"+$texes[j].f1+"</a>" +
				"</li>";
		}
		$("#f2Lb>.lb-btn").html(html);

		var currindex = 0;
		var steCli = function(currindex){
			$("#f2Lb>.lb-btn>li").removeClass("color").eq(currindex).addClass("color");
		};

		$("#f2Lb>.lb-btn>li").click(function(){
			var currindex = $(this).index();
			$("#f2Lb>.lbt").animate({left:-952*currindex},300);

			steCli(currindex);
		});
		setInterval(function(){
			currindex++;
			if(currindex === 6){
				$("#f2Lb>.lbt").css({"left":"0"});
				currindex = 0;
			}else{
				$("#f2Lb>.lbt").animate({left:-952*currindex},300);
			}

			steCli(currindex);
		},4000);

	});



	/*****************f3-轮播图************************/
	$.get("json/json1.json",function(data){
		var $arr = data[7].f3lb;
		var html = "";

		for(var i = 0; i < $arr.length;i++){
			html+="<div class = \"lb-x\">"
				+"<img src = \""+$arr[i].pic+"\"/>"
				+"</div>";
		}
		html+="<div class = \"lb-x\">"
			+"<img src = \""+$arr[0].pic+"\"/>"
			+"</div>";
		$("#f3Lb>.lbt").html(html);

		var $texes = data[8].f3Txt;
		var html = "";
		for(var j = 0;j<$texes.length;j++){
			html+="<li>" +
				"<a href=\"##\">"+$texes[j].f1+"</a>" +
				"</li>";
		}
		$("#f3Lb>.lb-btn").html(html);

		var currindex = 0;
		var steCli = function(currindex){
			$("#f3Lb>.lb-btn>li").removeClass("color").eq(currindex).addClass("color");
		};

		$("#f3Lb>.lb-btn>li").click(function(){
			var currindex = $(this).index();
			$("#f3Lb>.lbt").animate({left:-952*currindex},300);

			steCli(currindex);
		});
		setInterval(function(){
			currindex++;
			if(currindex === 6){
				$("#f3Lb>.lbt").css({"left":"0"});
				currindex = 0;
			}else{
				$("#f3Lb>.lbt").animate({left:-952*currindex},300);
			}

			steCli(currindex);
		},4000);

	});




	/*****************f4-轮播图************************/
	$.get("json/json1.json",function(data){
		var $arr = data[9].f4lb;
		var html = "";

		for(var i = 0; i < $arr.length;i++){
			html+="<div class = \"lb-x\">"
				+"<img src = \""+$arr[i].pic+"\"/>"
				+"</div>";
		}
		html+="<div class = \"lb-x\">"
			+"<img src = \""+$arr[0].pic+"\"/>"
			+"</div>";
		$("#f4Lb>.lbt").html(html);

		var $texes = data[10].f4Txt;
		var html = "";
		for(var j = 0;j<$texes.length;j++){
			html+="<li>" +
				"<a href=\"##\">"+$texes[j].f1+"</a>" +
				"</li>";
		}
		$("#f4Lb>.lb-btn").html(html);

		var currindex = 0;
		var steCli = function(currindex){
			$("#f4Lb>.lb-btn>li").removeClass("color").eq(currindex).addClass("color");
		};

		$("#f4Lb>.lb-btn>li").click(function(){
			var currindex = $(this).index();
			$("#f4Lb>.lbt").animate({left:-952*currindex},300);

			steCli(currindex);
		});
		setInterval(function(){
			currindex++;
			if(currindex === 6){
				$("#f4Lb>.lbt").css({"left":"0"});
				currindex = 0;
			}else{
				$("#f4Lb>.lbt").animate({left:-952*currindex},300);
			}

			steCli(currindex);
		},4000);

	});

	/*****************f5-轮播图************************/
	$.get("json/json1.json",function(data){
		var $arr = data[11].f5lb;
		var html = "";

		for(var i = 0; i < $arr.length;i++){
			html+="<div class = \"lb-x\">"
				+"<img src = \""+$arr[i].pic+"\"/>"
				+"</div>";
		}
		html+="<div class = \"lb-x\">"
			+"<img src = \""+$arr[0].pic+"\"/>"
			+"</div>";
		$("#f5Lb>.lbt").html(html);

		var $texes = data[12].f5Txt;
		var html = "";
		for(var j = 0;j<$texes.length;j++){
			html+="<li>" +
				"<a href=\"##\">"+$texes[j].f1+"</a>" +
				"</li>";
		}
		$("#f5Lb>.lb-btn").html(html);

		var currindex = 0;
		var steCli = function(currindex){
			$("#f5Lb>.lb-btn>li").removeClass("color").eq(currindex).addClass("color");
		};

		$("#f5Lb>.lb-btn>li").click(function(){
			var currindex = $(this).index();
			$("#f5Lb>.lbt").animate({left:-952*currindex},300);

			steCli(currindex);
		});
		setInterval(function(){
			currindex++;
			if(currindex === 6){
				$("#f5Lb>.lbt").css({"left":"0"});
				currindex = 0;
			}else{
				$("#f5Lb>.lbt").animate({left:-952*currindex},300);
			}

			steCli(currindex);
		},4000);

	});



	/***************f6-pic*******************/

	$.get("json/json1.json",function(data){
		var $arr = data[13].f6pic;
		var html = "";
		for(var i = 0;i<$arr.length;i++){
			html +="<li>"+
					"<dl>"+
					"<dt>"+
					"<img src = \""+$arr[i].pic+"\"/>"+
					"</dt>"+
					"<dd>"+$arr[i].count+"</dd>"+
					"<p>"+
					"<i>"+$arr[i].price+"</i>"+
					"<del>"+$arr[i].onprice+"</del>"+
					"</p>"+
					"<div class = \"aaa\">"+$arr[i].zhe+"</div>"+
					"</dl>"+
					"<div class = \"saoma\">"+
					"<img src = \"images/smoll/saoma.jpg\"/>"+
					"</div>"+
					"</li>";
		}
		$(".f6-pic>ul").html(html);





		$(".f6-pic>ul>li").mouseenter(function(){
		var $index = $(this).index();
		$(".f6-pic>ul>li>.saoma").removeClass("active").eq($index).addClass("active");
		});
		$(".f6-pic>ul").mouseleave(function(){

			$(".f6-pic>ul>li>.saoma").removeClass("active");
		})
	});

	$.get("json/json1.json",function(data){
		var $arr = data[14].pinpai;
		var html = "";
		for(var i = 0;i<$arr.length;i++){
			html+="<li>" +
				  "<a href=\"##\">" +
					"<img src = \""+$arr[i].pic+"\"/>" +
					"</a>" +
					"</li>";
		}
		$("#pp>ul").html(html);

	});








	/********************侧边栏*******************/
	$.get("json/json1.json",function(data){
			var $arr = data[15].cbl;

		$.each($arr,function(i,o){
			//console.log(o);
			var $xing = $("<div class =\"cb1\">"+
				"<div class =\"cb1TOP\">"+
				"<img src = \""+ o.pic+"\"/>"+
				"<h4>"+o.fenlei+"</h4>"+
				"<span>> </span>"+
				"</div>"+
				"<div class = \"cb1bot\">"+

				"</div>"+
				"</div>");

			$xing.appendTo("#cblbox");
			$.each(o.lis,function(j,k){
				//console.log(k);
				var $zixiang = $("<a href=\"##\">"+ k.li1+"</a>");
				$zixiang.appendTo("#cblbox>.cb1>.cb1bot:eq("+i+")");

			});

		});



		$("#cblbox>.cb1").mouseenter(function(){
			var $index = $(this).index();
			$("#cbRbox>.cblB1").removeClass("active").eq($index).addClass("active");
		});
		$("#cbRbox").mouseleave(function(){
			$("#cbRbox>.cblB1").removeClass("active")
		});
	});

/******************右侧子导航**********************/
		$(window).scroll(function(){
			if($(window).scrollTop()>$(window).height()){
				$(".right>.t1").fadeIn(400);
			}else{
				$(".right>.t1").fadeOut(400);
			}




			if($(".f1-l").offset().top <$(window).height()+$(window).scrollTop()&&$(".f2-l").offset().top>$(window).height()+$(window).scrollTop()){
				$(".left>.left1>a").css({
					"background":"url(images/zhenghe.png) no-repeat -170px -54px"
				});
			}else{
				$(".left>.left1>a").css({
					"background":"url(images/zhenghe.png) no-repeat -84px -54px"
				});
			}




			if($(".f2-l").offset().top<$(window).height()+$(window).scrollTop()&&$(".f3-l").offset().top>$(window).height()+$(window).scrollTop()){
				$(".left2>a").css({
					"background":"url(images/zhenghe.png) no-repeat -170px -88px"
				});
			}else{
				$(".left2>a").css({
					"background":"url(images/zhenghe.png) no-repeat -84px -88px"
				});
			}





			if($(".f3-l").offset().top<$(window).height()+$(window).scrollTop()&&$(".f4-l").offset().top>$(window).height()+$(window).scrollTop()){
				$(".left3>a").css({
					"background":"url(images/zhenghe.png) no-repeat -170px -120px"
				});
			}else{
				$(".left3>a").css({

					"background":"url(images/zhenghe.png) no-repeat -84px -120px"
				});

			}






			if($(".f4-l").offset().top<$(window).height()+$(window).scrollTop()&&$(".f5-l").offset().top>$(window).height()+$(window).scrollTop()){
				$(".left>.left4>a").css({
					"background":"url(images/zhenghe.png) no-repeat -170px -157px"
				});
			}else{
				$(".left>.left4>a").css({

					"background":"url(images/zhenghe.png) no-repeat -84px -157px"
				});
			}

			if($(".f5-l").offset().top<$(window).height()+$(window).scrollTop()&&$(".f6-l").offset().top>$(window).height()+$(window).scrollTop()){
				$(".left>.left5>a").css({

					"background":"url(images/zhenghe.png) no-repeat -170px -188px"
				});
			}else{
				$(".left>.left5>a").css({
					"background":"url(images/zhenghe.png) no-repeat  -84px -188px"
				});
			}

			if($(".f6-l").offset().top<$(window).height()+$(window).scrollTop()&&$(".sm-back").offset().top>$(window).height()+$(window).scrollTop()){
				$(".left>.left6>a").css({

					"background":"url(images/zhenghe.png) no-repeat -170px -219px"
				});
			}else{
				$(".left>.left6>a").css({
					"background":"url(images/zhenghe.png) no-repeat  -84px -222px"
				});
			}


		});


		$(".right>.t1").click(function(){
			$("html,body").animate({
				scrollTop:0
			},600);
		});


});








